# Maintainer: https://github.com/cathaysia
_realname=cppcoro
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=r390.a87e97f
pkgrel=1
pkgdesc=" A library of C++ coroutine abstractions for the coroutines TS (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=("MIT")
url="https://github.com/lewissbaker/cppcoro"
makedepends=('git')
_commit='a87e97f'
source=("${_realname}::git+https://github.com/lewissbaker/${_realname}.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_realname}"
  printf "r%s.%s" "$(git rev-list --count "${_commit}")" "$(git rev-parse --short "${_commit}")"
}

build(){
  # replace all std::experimental with std
function scan_dir(){
  for file in `ls $1` 
  do
      if [ -d $1"/"$file ] 
      then 
        scan_dir $1"/"$file
      else 
        sed 's/std::experimental/std/g' $1"/"$file | sed 's/experimental\///g' > $1"/"$file
      fi
  done
}
scan_dir "${srcdir}/cppcoro/include/cppcoro/"
}
package() {
  mkdir -p "${pkgdir}${MINGW_PREFIX}/"
  cp -r "${srcdir}/cppcoro/include/" "${pkgdir}${MINGW_PREFIX}/include/"
}
